package com.application.spider.model.alias;

import java.util.HashMap;
import java.util.Map;

import com.application.spider.entities.alias.AttributeDataType;
import com.application.spider.entities.alias.DataType;

public class ManagerSinonimos {

	private Map<DataType,Map<AttributeDataType, Map<String, String>>> alias;
	
	public ManagerSinonimos() {
		alias = new HashMap<DataType, Map<AttributeDataType,Map<String,String>>>();
		Map<String,String> aliasMap = new HashMap<String, String>();
		Map<AttributeDataType, Map<String, String>> attributeDataTypes = new HashMap<AttributeDataType, Map<String,String>>();
		
		aliasMap.put("Ciudad Autónoma de Buenos Aires", "Capital Federal");
		attributeDataTypes.put(AttributeDataType.provincia, aliasMap);
		alias.put(DataType.sede, attributeDataTypes);
		
		aliasMap = new HashMap<String, String>();
		aliasMap.put("VÍA FACEBOOK", "FaceBook");
		aliasMap.put("VÍA TWITTER", "Twitter");
		aliasMap.put("VÍA YOU TUBE", "YouTube");
		attributeDataTypes.put(AttributeDataType.nombre, aliasMap);
		alias.put(DataType.redSocial, attributeDataTypes);

	}
	public Map<String, String> getAlias(DataType dataType,AttributeDataType attributeDataType) {
		Map<String, String> map = null;
		if(alias.containsKey(dataType)){
			if(alias.get(dataType).containsKey(attributeDataType)){
				map = alias.get(dataType).get(attributeDataType);
			}
		}
		return map;
	}
	
	public void addAlias(DataType dataType,AttributeDataType attributeDataType,String key,String value){
		Map<AttributeDataType, Map<String, String>> 	attributeDataTypes = null;
		Map<String,String> 								aliasMap = null;
		if(alias.containsKey(dataType)){
			if(alias.get(dataType).containsKey(attributeDataType)){
				alias.get(dataType).get(attributeDataType).put(key, value);
			}else{
				aliasMap = new HashMap<String, String>();
				
				aliasMap.put(key, value);								
				alias.get(dataType).put(attributeDataType, aliasMap);
			}
		}else{
			aliasMap = new HashMap<String, String>();
			attributeDataTypes = new HashMap<AttributeDataType, Map<String,String>>();
			
			aliasMap.put(key, value);
			attributeDataTypes.put(attributeDataType, aliasMap);
			alias.put(dataType, attributeDataTypes);
		}
	}
	public Boolean containsKey(DataType dataType,AttributeDataType attributeDataType,String value) {
		Boolean encontrado = Boolean.FALSE;
		if(alias.containsKey(dataType)){
			if(alias.get(dataType).containsKey(attributeDataType)){
				encontrado = alias.get(dataType).get(attributeDataType).containsKey(value); 
			}
		}
		return encontrado;
	}
	public String getValue(DataType dataType, AttributeDataType attributeDataType, String key) {
		String value = "";
		if(alias.containsKey(dataType)){
			if(alias.get(dataType).containsKey(attributeDataType)){
				value = alias.get(dataType).get(attributeDataType).get(key); 
			}
		}
		return value;
	}
}
